import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '课程名称',
    align: 'center',
    dataIndex: 'title',
  },
  {
    title: '课程描述',
    align: 'center',
    dataIndex: 'description',
  },
  {
    title: '教师姓名',
    align: 'center',
    dataIndex: 'teachername',
  },
  // {
  //   title: '课程图片',
  //   align: "center",
  //   dataIndex: 'imageurl',
  //   customRender: render.renderImage,
  // },
  {
    title: '选课人数',
    align: 'center',
    dataIndex: 'curriculavariablecount',
  },
  {
    title: '课程详情',
    align: 'center',
    dataIndex: 'coursedetail',
  },
  {
    title: '课程时长',
    align: 'center',
    dataIndex: 'courseduration',
  },
  {
    title: '课程节数',
    align: 'center',
    dataIndex: 'coursepitchnumber',
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '课程名称',
    field: 'title',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: '教师姓名',
    field: 'teachername',
    component: 'Input',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '课程名称',
    field: 'title',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入课程名称!' }];
    },
  },
  {
    label: '课程描述',
    field: 'description',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入课程描述!' }];
    },
  },
  {
    label: '教师姓名',
    field: 'teachername',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入教师姓名!' }];
    },
  },
  // {
  //   label: '课程图片',
  //   field: 'imageurl',
  //   component: 'JImageUpload',
  //   componentProps:{
  //   },
  //   dynamicRules: ({model,schema}) => {
  //     return [
  //             { required: true, message: '请输入课程图片!'},
  //            ];
  //   },
  // },
  {
    label: '选课人数',
    field: 'curriculavariablecount',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入选课人数!' }];
    },
  },
  {
    label: '课程详情',
    field: 'coursedetail',
    component: 'JEditor',
  },
  {
    label: '课程时长',
    field: 'courseduration',
    component: 'Input',
  },
  {
    label: '课程节数',
    field: 'coursepitchnumber',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
